Brief Full Advanced Search Search Tips
|  |  | To access the contents, click the chapter and section titles. Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 Search this book:
Previous | Table of Contents | Next
The Command property mentioned earlier sends commands to an MCI device. Set the Multimedia control’s Command property to a valid MCI command string, and the command is sent to the open MCI device associated with the control. The valid commands are Open, Close, Play, Pause, Stop, Back, Step, Prev, Next, Seek, Record, Eject, Sound, or Save. The command is executed immediately, and the error code is stored in the Error property. The TimeFormat property sets the format that the device uses to measure time. Several different time formats are available; the Visual Basic Help system offers detailed information. Knowing the current time format is essential, because the From, To, Length, TrackLength, Position, TrackPosition, and Start properties all use the current time format. Each type of device has a default time format that can be changed if desired. Note, however, that certain devices do not support all the available time formats. If you attempt to set the TimeFormat property to an unsupported value, the setting is ignored and the old setting is retained. The default time format settings for the most common devices are shown in Table 16.5. Table 16.4 Mode property values.
Value | Constant | Meaning
--- | --- | ---
524 | mciNotOpen | Device is not open.
525 | mciStop | Device is stopped.
526 | mciPlay | Device is playing.
527 | mciRecord | Device is recording.
528 | mciSeek | Device is seeking.
529 | mciPause | Device is paused.
530 | mciReady | Device is ready.
Table 16.5 Default time format settings for common devices.
Constant | Value | Default | Description
--- | --- | --- | ---
mciFormatMilliseconds | 0 | WAV and MIDI | Time is expressed in milliseconds.
mciFormatMfs | 2 | CDAudio | Minutes, seconds, and frames are packed into a four-byte type Long. The least significant byte holds the minutes value, the next byte holds seconds, the next byte holds frames, and the most significant byte is not used.
mciFormatFrames | 3 | AVI (digital video) | Time is expressed in frames.
Upon examining Table 16.5, you may wonder why the time format used for CDAudio includes frames. If you insert an audio CD in your CD-ROM drive and open the device, the Multimedia control returns the TimeFormat value. I don’t see what use the Frame value plays in this format, but we can’t argue with Microsoft. The Orientation property determines whether the Multimedia control is displayed horizontally (the default) or vertically. Set this property to the constant mciOrientHorz (value = 0) for a horizontal control, or to mciOrientVert (value = 1) for a vertical control. The Wait property works just like the Wait argument in a command sent directly to the MCI. Set Wait to True to have execution return to your program only after the MCI has completed the current operation. If Wait is False (the default), execution returns immediately. Multimedia Control Events The Multimedia control supports only eight events. Two of these—DragOver and DragDrop —operate the same as events of the same name associated with many other Visual Basic controls. The other six events are unique to the Multimedia control. Some of these events enhance the usefulness of the Multimedia control, allowing us to do things that would not be possible by sending commands directly to the MCI. Four of the events are related to the individual buttons on the control. Each of the buttons—Back, Eject, Next, Pause, Play, Prev, Record, Step, and Stop—has its own discrete event procedures. They are as follows: The ButtonClick event occurs when the button is clicked. The default is for each button, when clicked, to send the corresponding command to the MCI. These commands are shown in Table 16.6. You can specify additional code to be executed with (or instead of) the button’s command when it is clicked on. The skeleton of each button click procedure looks like this:
    Sub MMControl_ButtonClick (Cancel As Integer)

    End Sub
MMControl is the name of the Multimedia control, and Button is the name of the button (Back, Eject, and so on). When the button is clicked, code placed in the event procedure is executed. If the Cancel argument is left at its default value of False, the button’s command is sent to the MCI after the code in the procedure is executed. If Cancel is set to True, the command is not sent (but the code in the procedure is still executed). It’s easy to see how flexible this arrangement can be: When a button is clicked on, you can execute your own code, the default command, or both. The ButtonGotFocus event procedure executes when the button receives the focus, and the ButtonLostFocus procedure executes when the button loses the focus. No special features are attached to these event procedures. The ButtonCompleted event is triggered when the MCI operation started by a Multimedia control button click is complete. For example, if the user clicks on the Play button, the PlayCompleted event procedure will be executed when the play is completed. The ButtonCompleted event procedure looks like this:
    Sub MMControl_ButtonCompleted (Errorcode As Long)

    End Sub
Previous | Table of Contents | Next